home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / decprom / ds5000.md / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-31  |  2.2 KB  |  105 lines

  1. /* 
  2.  * main.c --
  3.  *
  4.  *    The main program for booting.
  5.  *
  6.  * Copyright 1986 Regents of the University of California
  7.  * All rights reserved.
  8.  */
  9.  
  10. #ifdef  notdef
  11. static char rcsid[] = "$Header: /sprite/src/boot/decprom/ds3100.md/RCS/main.c,v 1.2 90/06/27 14:57:11 shirriff Exp $ SPRITE (Berkeley)";
  12. #endif not lint
  13.  
  14.  
  15. #include "sprite.h"
  16. #include "kernel/machMon.h"
  17. #include "fsBoot.h"
  18. #include "boot.h"
  19. #define NO_PRINTF
  20.  
  21. extern Fs_Device fsDevice;        /* Global FS device descriptor */
  22.  
  23. void Exit();
  24.  
  25. /*
  26.  *----------------------------------------------------------------------
  27.  *
  28.  * main --
  29.  *
  30.  *      This gets arguments from the PROM, calls other routines to open
  31.  *      and load the program to boot, and then transfers execution to that
  32.  *      new program.
  33.  *
  34.  * Results:
  35.  *    None.
  36.  *
  37.  * Side effects:
  38.  *    None.
  39.  *
  40.  *----------------------------------------------------------------------
  41.  */
  42.  
  43. main(argc,argv,argenv)
  44. int argc;
  45. char **argv;
  46. char **argenv;
  47. {
  48.     ReturnStatus status;
  49.     register int index;            /* Loop index */
  50.     register int entry;            /* Entry point of boot program */
  51.     Fsio_FileIOHandle *handlePtr;    /* Handle for boot program file */
  52.     char *fileName = "sprite";
  53.     register char *i;
  54.     char *boot;
  55.  
  56.     /*
  57.      * Set up state about the disk.
  58.      */
  59.     Mach_MonPrintf("Performing dec disk boot\n");
  60.     bzero((char *) &fsDevice, sizeof(fsDevice));
  61.     status = FsAttachDisk(&fsDevice);
  62.     if (status != SUCCESS) {
  63.     Mach_MonPrintf("Can't attach disk, status <0x%x>\n",  status);
  64.     goto exit;
  65.     }
  66.     boot = Mach_MonGetenv("boot");
  67.     for (i=boot;*i != '\0'; i++) {
  68.     if (i[0]=='/' && i[1] != '\0') {
  69.         fileName = i+1;
  70.     }
  71.     }
  72. #ifndef NO_PRINTF
  73.     Mach_MonPrintf("Open File \"%s\"\n", fileName);
  74. #endif
  75.     /*
  76.      * Open the file to bootstrap.
  77.      */
  78.     status = Fs_Open(fileName, FS_READ, 0, &handlePtr);
  79.     if (status != SUCCESS) {
  80.     Mach_MonPrintf("Can't open \"%s\", <%x>\n", fileName, status);
  81.     goto exit;
  82.     }
  83.     entry = FileLoad(handlePtr);
  84.     if (entry != -1) {
  85. #ifndef NO_PRINTF
  86.     Mach_MonPrintf("Transferring to location 0x%x\n", entry);
  87. #endif
  88.     Boot_Transfer(entry,argc,argv,argenv);
  89.     }
  90. exit:
  91.     return;
  92. }
  93.  
  94. /*
  95.  * Exit is called by start.s
  96.  */
  97. void
  98. Exit()
  99. {
  100.     /*
  101.      * Return to start.s and then the PROM monitor.
  102.      */
  103.     return;
  104. }
  105.